package first_practice;

/**
 * @author ZhiWen Ren
 * @version 1.0
 * @description: LeetCode-53-最大子数组和
 * @date 2025/3/18 16:50
 */
public class Solution53 {
    public int maxSubArray(int[] nums) {
        // 动态规划
        int pre = 0, ans = nums[0];
        for (int x : nums) {
            pre = Math.max(pre + x, x);
            ans = Math.max(ans, pre);
        }
        return ans;
    }
}

